package de.hwr.it11.dectree.dialog;

import java.io.File;

import net.miginfocom.swt.MigLayout;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

import de.hwr.it11.dectree.language.Messages;
import de.hwr.it11.dectree.model.Project;

/**
 * Der <code>HelpDialog</code> stellt die integrierte Hilfe-HTML dar.
 */
public class HelpDialog extends AProjectDialog {

	/**
	 * Erstellt einen neuen <code>HelpDialog</code>.
	 * 
	 * @param pParentShell
	 *            die <code>Shell</code>
	 * @param pProject
	 *            das zu verwendende <code>Project</code>
	 * @param pDialogTitle
	 *            der Titel des Dialoges
	 */
	public HelpDialog(Shell pParentShell, Project pProject, String pTitle) {
		super(pParentShell, pProject, pTitle);
	}



	@Override
	protected void configureShell(Shell pShell) {
		super.configureShell(pShell);
		pShell.setImage(SWTResourceManager.getImage(getClass(), "/img/help.png"));
	}



	@Override
	protected Control createDialogArea(Composite pParent) {
		Composite composite = new Composite(pParent, SWT.NONE);
		composite.setLayout(new MigLayout("fill, ins 0"));
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		Browser browser = new Browser(composite, SWT.NONE);
		browser.setLayoutData("hmin 0, wmin 0, grow");
		String url = new File("help/help-" + Messages.getLanguage() + ".html").getAbsolutePath();
		browser.setUrl(url);

		return composite;
	}



	@Override
	protected Point getInitialSize() {
		return new Point(900, 500);
	}



	@Override
	protected boolean isResizable() {
		return true;
	}



	@Override
	protected Control createButtonBar(Composite pParent) {
		// Der Hilfe-Dialog braucht keine Buttons
		return null;
	}

}
